package org.gap.jseed.contract;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import org.gap.jseed.injection.ClassWriter;

public class NotNullValidation extends ValidationWriter {
	@Override
	public void injectBehavior(ClassWriter javaWriter, Method method, Annotation annotation) {
		for (int i = 1; i <= method.getParameterTypes().length; i++) {
			String preCondition = createTestCondition("$" + i + "!= null") + createSpecialConditionViolationException("first parameter " + method.getParameterTypes()[0].getSimpleName() + " cannot be NULL");
			javaWriter.insertBefore(method, preCondition);
		}
	}
}
